

function Intro()
	FadeOut 		{time = 0.01, block = true}
	Wait 			{time = 3}
	FadeIn 			{time = 4, block = false}
	Sound			{file = "HL2_Nectarium.mp3", pos = pos("Player"), volume = 0.4, attach = "Player", block = false}
end


function EntranceLift()
	--start moving the platform down the tunnel, will take 16 seconds
	Shake 	{time = 1, power = 1, degrade = 1}
	Shake 	{time = 16, power = .1, degrade = 0}
	Sound 	{file = "platformClash.wav", pos = pos("Platform1"), block = false}
	Sound 	{file = "platformMove.wav", pos = pos("Platform1"), attach = "Platform1", time = 16, block = false}
	Move	{act = "Platform1", a = pos("startLift1"), b = pos("midLift"), time = 16, block = false}
	--turn on the lights 2 by two as we go down
	for i = 1, 4 do
		local li = 2*i - 1
		local i = i
		--each should turn on over 0.5 seconds
		Sound		{file = "light_on2.mp3", pos = pos("liftLight["..li.."]"), block = false }
		ShiftColor	{act = "liftLight["..li.."]", time = 0.1, a = color(0, 0, 0), b = color(1, 1, 1), block = false}
		ShiftColor	{act = "liftLight["..(li+1).."]", time = 0.1, a = color(0, 0, 0), b = color(1, 1, 1), block = true}
		--wait for 4 - 0.5 seconds
		Wait		{time = 3.8}
	end
	Sound		{file = "platformClash.wav", pos = pos("Platform1"), block = false}
	Shake		{power = 0.5}
	Wait		{time = 2}
	--move the platform and light as a pair
	Sound		{file = "platformMove.wav", pos = pos("Platform1"), time = 12, attach = "Platform1", block = false}
	Shake 		{time = 12, power = .1, degrade = 0}
	Move		{act = "Platform1", a = pos("midLift"), b = pos("endLift"), time = 12, block = false}
	Move		{act = "backLight1", a = pos("lightStartMark"), b = pos("lightEndMark"), time = 12, block = true}				--HACK: rename to backlight1
	--stop the platform and shake the screen hard
	Sound		{file = "platformClash.wav", pos = pos("Platform1"), block = false}
	Shake		{power = 1.5}
	--we've now reached the bottom of the shaft
end

--HACK: we should


--sprite radius too small, suspicious
--"first alive object" in protected cache went WAAAAAAAY out of range
	--this points to a problem in this buffer


	--stairs:
		--  110, -60
	--trap door
		--  104, -28
	--lift
		-- -10,   30


--stairBase[i]
--stairRamp[i]

--TODO: ADD Vec2 to the environment acess

--take 16 seconds to raise the stair case
function RaiseStairs()
	--traverse the 4 stairs

	--add 1 to y, add 2 to x

	local basePosStart = pos("stairBase[1]")
	local rampPosStart = pos("stairRamp[1]")


	for i = 1, 5 do
		local i = i
		local c = i -1
		--compute the start and end positions for the base and ramps
		local baseStart = basePosStart + pos(2*c, 0)
		local rampStart = rampPosStart + pos(2*c, 0)
		local baseEnd 	= basePosStart + pos(2*c, c)
		local rampEnd 	= rampPosStart + pos(2*c, c)
		--we move the base and the ramp as a pair
		Move		{act = "stairBase["..i.."]",a = baseStart, b = baseEnd, time = 4, block = false}
		Move		{act = "stairRamp["..i.."]",a = rampStart, b = rampEnd, time = 4, block = false}
		Shake 		{time = 2, power = .05, degrade = 0}
		Sound		{file = "rockSlide.wav", time = 5, pos = pos("stairBase["..i.."]"), block = false}
		--wait for 0.2 second
		Wait		{time = 0.4}
	end


--rockSlide

end

--should take 5 seconds to open the trap door in the center of the room
function OpenTrapDoor()
	Shake 	{time = 10, power = .1, block = false}
	Sound	{file = 'rockSlide.wav', time = 10, block = false}
	Move	{act = "trapDoor", a = pos("doorCenter"), b = pos("doorSide") - pos(4, 0), time = 10}
	Shake	{time = 1, power = 0.5}
	Sound	{file = 'platformClash.wav'}
end












--TODO: add speed parameter to the Move command
--add reset command that resets state
--


--we can do some basic scripted AI here I think
	--Animate
	--Move
	--
--[[
function RunSoldier1()
	--make the soldier run to the new location and fire at the player
	act "soldier1"
	dir "left"
		Animate		{anim = "run"}
		Move		{a = pos("solStart"), b = pos("solEnd"), speed = 60}
		Animate		{anim = "fire"}
	reset()
	--I guess the death animation will be dealt with in the soldiers code
end


function RunSoldier2()
	--make the soldier run to the new location and fire at the player
	act "soldier2"
		Animate		{anim = "run", dir = 'left'}
		Move		{a = pos("sol2Start"), b = pos("sol2End"), speed = 60}
		Animate		{anim = "aim", dir = 'leftUp'}
	reset()
end

function ShootSoldier2()
	Animate		{act = 'soldier2', anim = "fire", dir = 'leftUp'}
end


]]






--act "soldier1"
--	do
--	end

	--Animate		{act = "soldier1", anim = "run", dir = 'left')
	--Move		{act = "soldier1", a = pos("solStart"), b = pos("solEnd"), speed = 3}
	--Animate		{act = "soldier1", anim = "fire", dir = 'left'}













--startList1
--midLift
--endLift

--doorCenter
--doorSide

--lightStartMark
--lightEndMark



--activate start markers


--TODO:
--replace target with act
--replace intensity with power
--rename to backlight1 (that following light)
--make SetDayTime function
--modify sound command to loop until the time is over
	--do this by looping indefinitley and then killing the sound player, set persistence to false
--create a panel named 'panel'
-- we should just have an option to pass in an actor name for position parameters


--needed sounds:
-- platformClash.mp3
-- platformMove.mp3
-- lightOn.mp3
-- panelClash.mp3

